package cn.butcher21.controller;


import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * butcher create in 2021/04/26/19:26
 */
@WebServlet("/addCookie")
public class MakeCookie extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String projectNum = request.getParameter("projectNum");
        Cookie cookie = new Cookie("project", projectNum);
        cookie.setMaxAge(1000 * 60 * 60 * 24 * 24);
        cookie.setPath(request.getContextPath());
        response.addCookie(cookie);
    }
}
